<template>
  <div class="capital-list">
    <a-form class="search-form" :form="form">
      <a-row :gutter="gutter">
        <a-col :lg="14" :xl="12" :xxl="10">
          <a-form-item label="查询时间">
            <date :value="searchTime" :status="3" @change="dateChange"/>
          </a-form-item>
        </a-col>
        <a-col :lg="10" :xl="10" :xxl="10">
          <div class="top-btns">
            <a-button type="primary" @click="searchList">查询</a-button>
            <a-button type="primary" @click="exportPop"><a-icon type="download" />导出商家流水</a-button>
          </div>
        </a-col>
      </a-row>
     </a-form>
    <div class="table-wrapper">
      <a-table
        :columns="columns"
        :dataSource="capitalData"
        rowKey="index"
        :loading="loading"
        :pagination="pagination"
      >
      </a-table>
    </div>
    <div class="modal-wrap">
      <!-- 导出弹窗 -->
      <export-list ref="exportBand" exportApi="capitalNumber"/>
    </div>
  </div>
</template>

<script>
import { subsidyCapital } from '../../store/financialApi'
export default {
  name: 'capitalNumber',
  data () {
    return {
      searchTime: [], // 导出时间
      startTime: 0,
      endTime: 0,
      loading: false,
      pagination: false,
      form: this.$form.createForm(this),
      gutter: {
        xs: 8,
        sm: 16,
        md: 16,
        lg: 24,
        xl: 24,
        xxl: 48
      },
      columns: [
        {
          dataIndex: 'index',
          title: '方式',
        },
        {
          title: '微信',
          dataIndex: 'wechat'
        },
        {
          dataIndex: 'ali',
          title: '支付宝',
        },
        {
          title: '余额',
          dataIndex: 'balance'
        },
        {
          dataIndex: 'deduction',
          title: '优惠券',
        },
        {
          title: '手续费',
          dataIndex: 'fee'
        },
        {
          title: '合计',
          dataIndex: 'total'
        }
      ],
      capitalData: []
    }
  },
  mounted () {
    this.pageInit()
  },
  methods: {
    // 列表数据
    pageInit () {
      subsidyCapital({
        start_time: this.startTime,
        end_time: this.endTime
      }).then(res => {
        console.log(res)
        let datas = res.data
        this.capitalData = [
          {
            index: '会员充值',
            wechat: datas.member_recharge_wechat,
            ali: datas.member_recharge_ali,
            balance: 0,
            deduction: 0,
            fee: 0,
            total: datas.member_recharge_sum
          }, {
            index: '服务商充值',
            wechat: datas.partner_recharge_wechat,
            ali: datas.partner_recharge_ali,
            balance: 0,
            deduction: 0,
            fee: 0,
            total: datas.partner_recharge_sum
          }, {
            index: '会员购券',
            wechat: datas.buy_wechat,
            ali: datas.buy_ali,
            balance: datas.buy_balance,
            deduction: 0,
            fee: datas.buy_fee,
            total: datas.member_buy_sum
          }, {
            index: '会员买单',
            wechat: datas.consume_wechat,
            ali: datas.consume_ali,
            balance: datas.consume_balance,
            deduction: datas.consume_deduction,
            fee: datas.consume_merchant_fee,
            total: datas.merchant_settle_sum
          }, {
            index: '合计',
            wechat: datas.sum_wechat,
            ali: datas.sum_ali,
            balance: datas.sum_balance,
            deduction: datas.sum_deduction,
            fee: datas.sum_fee,
          }
        ]
      })
    },
    // 查询列表
    searchList () {
      this.pageInit()
    },
    // 导出按钮弹出弹窗
    exportPop () {
      this.$refs.exportBand.openPop()
    },
    // 查询时间
    dateChange({ date, start_time, end_time }) {
      this.searchTime = date
      this.startTime = start_time
      this.endTime = end_time
    }
  }
}  
</script>

<style>

</style>
